var deving_handler = function(){
    Ext.Msg.alert('系统提示', '尚未实现');
};

var default_success_function = function(response, opts) {
  var resp = Ext.decode(response.responseText);
  if(resp.message){
    Ext.Msg.alert('系统提示', resp.message);
  }
};

var default_success_function = function(response, opts) {
  var resp = Ext.decode(response.responseText);
  if(resp.message){
    Ext.Msg.alert('系统提示', resp.message);
    return;
  }
  if(resp.errormsg){
    Ext.Msg.alert('系统提示', resp.errormsg);
    return;
  }
};

var success_callback = function(response, opts) {
  return eval(response.responseText);
};

var json_callback = function(response, opts) {
  var ret=Ext.decode(response.responseText);
  if (ret.success && ret.message){
    alert(ret.message);
  }
  if (ret.success == false){
    alert('error:'+ret.message);
  }
};

var failure_callback = function(response, opts) {
  alert(response.responseText);
};

var execute_remote_extjs = function(url_for_extjs){
  Ext.Ajax.request({
    url: url_for_extjs,
    params:{format:'extjs'},
    success: success_callback,
    failure: failure_callback
  });
};

var open_window_with_json = function(response, opts) {
  var json=Ext.decode(response.responseText);
  new Ext.Window({layout:'fit',title:json.title,items:[json]}).show();
};

var open_window_from_remote_json = function(url_for_json){
  Ext.Ajax.request({
    url: url_for_json,
    params:{format:'extjs'},
    success: success_callback,
    failure: failure_callback
  });
};


var default_ajax_request_success_callback=function(response, options) {
    var jsret =  Ext.decode(response.responseText);
    if (jsret.return_type && jsret.return_type==='js' && jsret.run){
        return jsret.run(); //var win = jsret.run();
    } else {
        if (jsret.message){
            Ext.Msg.alert('系统提示', jsret.message);
        }
        if (jsret.errormsg){
            Ext.Msg.alert('错误', jsret.errormsg);
        }
        return false;
    }
};
var default_ajax_request_failure_callback = function(response, options) {
	Ext.Msg.alert('错误', '访问错误,请删除rul中的ticket参数及值,重试!');
    if (console){
        console.log(response);
    }
};
//执行远程的json
//execute_remote_extjson('/controller/action/xxx')
//execute_remote_extjson({url:'/controller/action/xxx',params:{}})
var execute_remote_extjson = function(options){
    if (Ext.isString(options)){
        options = {url:options};
    }
    var request_options={
        success: default_ajax_request_success_callback,
        failure: default_ajax_request_failure_callback
    };
    Ext.apply(request_options,options);
    Ext.Ajax.request(request_options);
};